/**
 * 
 */
package com.cyou.qb.common.domain;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;

import org.apache.commons.lang.time.DateUtils;

/**
 * @author zoudongchao
 *
 */
public class Winner implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = -5057651371286702698L;
	
	private int id;
	private int awardId;
	private int awardDetailId;
	private int activeId;
	private	int uCenterId;
	private String passport;
	private String nickname;
	private Date winTime;
	private Date createDate;
	
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public int getAwardId() {
		return awardId;
	}
	public void setAwardId(int awardId) {
		this.awardId = awardId;
	}
	public int getAwardDetailId() {
		return awardDetailId;
	}
	public void setAwardDetailId(int awardDetailId) {
		this.awardDetailId = awardDetailId;
	}
	public int getActiveId() {
		return activeId;
	}
	public void setActiveId(int activeId) {
		this.activeId = activeId;
	}
	public int getuCenterId() {
		return uCenterId;
	}
	public void setuCenterId(int uCenterId) {
		this.uCenterId = uCenterId;
	}
	public String getPassport() {
		return passport;
	}
	public void setPassport(String passport) {
		this.passport = passport;
	}
	public String getNickname() {
		return nickname;
	}
	public void setNickname(String nickname) {
		this.nickname = nickname;
	}
	public Date getWinTime() {
		return winTime;
	}
	public void setWinTime(Date winTime) {
		this.winTime = winTime;
	}
	public Date getCreateDate() {
		return createDate;
	}
	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}
	public String getWinTimeStr(){
		if(winTime==null||winTime.getTime()>System.currentTimeMillis())
			return "";
		Calendar thisTime = Calendar.getInstance();
		Date date = thisTime.getTime();
		long between =winTime.getTime()-date.getTime();
		if(date.getYear()!=winTime.getYear()){
			return date.getYear()-winTime.getYear()+"年前";
		}
		if(date.getMonth()!=winTime.getMonth()){
			return date.getMonth()-winTime.getMonth()+"月前";
		}
		Calendar win = Calendar.getInstance();
		win.setTime(winTime);
		if(win.get(Calendar.WEEK_OF_YEAR)!=thisTime.get(Calendar.WEEK_OF_YEAR)){
			return thisTime.get(Calendar.WEEK_OF_YEAR)-win.get(Calendar.WEEK_OF_YEAR)+"周前";
		}
		if(win.get(Calendar.DAY_OF_YEAR)!=thisTime.get(Calendar.DAY_OF_YEAR)){
			return thisTime.get(Calendar.DAY_OF_YEAR)-win.get(Calendar.DAY_OF_YEAR)+"天前";
		}
		if(win.get(Calendar.HOUR_OF_DAY)!=thisTime.get(Calendar.HOUR_OF_DAY)){
			return thisTime.get(Calendar.HOUR_OF_DAY)-win.get(Calendar.HOUR_OF_DAY)+"小时前";
		}
		
		int i = (int)(date.getTime()-winTime.getTime())/1000/60;
		if(i==0)
			return "刚刚";
		return i+"分钟前";
	}
	public static void main(String[] args) {
		Winner winner = new Winner();
		winner.setWinTime(new Date());
		System.out.println(winner.getWinTimeStr());
		
		winner.setWinTime(DateUtils.addMinutes(new Date(), -2));
		System.out.println(winner.getWinTimeStr());
		
		winner.setWinTime(DateUtils.addHours(new Date(), -2));
		System.out.println(winner.getWinTimeStr());
		
		winner.setWinTime(DateUtils.addDays(new Date(), -2));
		System.out.println(winner.getWinTimeStr());
		
		winner.setWinTime(DateUtils.addDays(new Date(), -10));
		System.out.println(winner.getWinTimeStr());
		
		winner.setWinTime(DateUtils.addDays(new Date(), -40));
		System.out.println(winner.getWinTimeStr());
		
		winner.setWinTime(DateUtils.addDays(new Date(), -90));
		System.out.println(winner.getWinTimeStr());
		
		winner.setWinTime(DateUtils.addDays(new Date(), -900));
		System.out.println(winner.getWinTimeStr());
	}
	
}
